<?php 
    $event = Event::model()->with('translate')->findByPk($model->event_id); 
    $user_created = Users::model()->findByPk($model->created_by);
    $user_updated = Users::model()->findByPk($model->updated_by);
    $seat_map = Ticket::model()->findByAttributes(array('event_id' => $model->event_id,'seat_map' => 1));
    // var_dump($user_created);die();
?>
<div class="page-content">
    <div class="row-fluid">
        <div class="span12">
            <div class="row-fluid">
                <div class="widget-box">
                    <div class="widget-header widget-header-flat">
                        <h4 class="smaller red"><?php echo $event->translate[1]->main_title; ?></h4>
                    </div>
                    <div class="widget-body">
                        <div class="widget-main">
                            
                                <dl id="dt-list-1" class="dl-horizontal">
                                    <dt>Event Code</dt>
                                    <dd><b class="red"><?php echo $model->event->event_code; ?></b></dd>
                                    <dt>Ticket Code</dt>
                                    <dd><b class="green"><?php echo $model->ticket_code; ?></b></dd>
                                    <dt>Ticket Type</dt>
                                    <dd><b class="blue"><?php echo $model->type_of_ticket; ?></b></dd>
                                    <dt>Ticket Description</dt>
                                    <dd><b class="blue"><?php echo $model->description_of_ticket; ?></b></dd>
                                    <dt>Ticket Code Org</dt>
                                    <dd><b class="blue"><?php echo $model->ticket_code_org; ?></b></dd>
                                    <dt>Price</dt>
                                    <dd><b class="red"><?php echo number_format($model->price); ?> VND / ticket</b></dd>
                                    <dt>Quantity</dt>
                                    <dd><b class="blue"><?php echo MyFunctionCustom::remain_quantity($model->quantity,$model->temp_quantity,null); ?></b></dd>
                                    <dt>Remain Quantity</dt>
                                    <dd>
                                        <?php $real_quantity = MyFunctionCustom::remain_quantity(null,$model->temp_quantity,$model->remain_quantity); ?>
                                        <?php if ($real_quantity < 10) : ?>
                                            <b class="red">
                                                <?php echo $real_quantity;  ?>
                                            </b>
                                        <?php else : ?>
                                            <b class="blue"><?php echo $real_quantity; ?></b>
                                        <?php endif; ?> 
                                    </dd>
                                    <dt>Created date</dt>
                                    <dd><b><?php echo date("d-M-Y",strtotime($model->date)); ?></b></dd>
                                    <dt>Created time</dt>
                                    <dd><b><?php echo date("H:i",strtotime($model->date)); ?></b></dd>
                                    <dt>Created by</dt>
                                    <dd><b><?php echo $user_created->first_name . ' ' . $user_created->last_name; ?></b></dd>
                                    <dt>Lastest Update Time</dt>
                                    <dd>
                                        <b class="green">
                                            <?php if($model->updated_date != null): ?>
                                            <?php echo date("d-M-Y / H:i",strtotime($model->updated_date) ); ?>
                                            <?php else : ?>
                                                Not Available
                                            <?php endif; ?>
                                        </b>
                                    </dd>
                                    <dt>Lastest Update User</dt>
                                    <dd>
                                        <b>
                                            <?php if($user_updated != null): ?>
                                            <?php echo $user_updated->first_name . ' ' . $user_updated->last_name; ?>
                                            <?php else : ?>
                                                Not Available
                                            <?php endif; ?>
                                        </b>
                                    </dd>
                                    <dt>Seat map</dt>
                                    <dd>
                                        <?php if(isset($seat_map)) : ?>
                                            <img src='<?php echo Yii::app()->baseUrl . "/timthumb.php?src=" . Yii::app()->baseUrl . "/data/pic/" . $seat_map->pic_seat_map . "&w=750"; ?>' /></dd>
                                        <?php else : ?>
                                            <b>Not Available</b>
                                        <?php endif; ?>
                                    </dd>
                                </dl>
                        </div>
                        
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>    